package com.china08.yxyapi.api.comm;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.entity.db.yxy.YxyQuesKnow;
import com.china08.yxyapi.model.ResModel;
import com.china08.yxyapi.service.updateresource.WeikeUpdateService;

@CrossOrigin
@RestController
public class UpdateWeikeAndQuesController {

    @Autowired
    private WeikeUpdateService ups;

    @RequestMapping(value = "/api_yw/comm/updweikeandques", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResModel process(@RequestBody ReqModel reqModel) {
        ResModel model = new ResModel();
        try {
            ups.updateWeikeBase(reqModel.knowledges);
            model.success("成功");
        } catch (Exception e) {
            model.error(e.getMessage() + "===========" + e.toString());
            e.printStackTrace();
        }
        return model;
    }

    protected static class ReqModel {
        public List<YxyQuesKnow> knowledges;
    }

}
